***** OPEN OUTPUT LOG FILE FOR APPENDIX E ANALYSES: "HARDIWRING MUTUAL COMMITTMENT" *****



*log "C:\Users\gk57526\Dropbox\Confirmation Dynamics Project (Jason Byers)\Appointee Tenure Project\Jason Byers\March 2023\DART (PRQ)\Output\Hardwiring Committment.APPENDIX E.04-21-2023.smcl" 

log using "C:\Users\Jason\Dropbox\Jason Byers\Co-Authored Projects\Projects with George Krause\Krause Projects\Confirmation Dynamics Project\Appointee Tenure Project\Jason Byers\March 2023\DART (PRQ)\Output\Hardwiring Committment.APPENDIX E.04-21-2023.smcl", replace



*******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************





**** APPENDIX E STATISTICAL ANALYSES: REPLICATE MANUSCRIPT MODELS -- INCLUSION OF POST-EMPLOYMENT UNIT EFFECTS TO CONTROL FOR SYSTEMATIC DIFFERENCES ATTRIBUTABLE TO DEPARTURE REASONS ***



** RETRIEVE SINGLE EVENT RECORDS DATABASE [N = 860 APPOINTEE OBSERVATIONS: 831 UNCENSORED OBSERVATIONS; 29 CENSORED OBSERVATIONS] **

use "C:\Users\Jason\Dropbox\Jason Byers\Co-Authored Projects\Projects with George Krause\Krause Projects\Confirmation Dynamics Project\Appointee Tenure Project\Jason Byers\March 2023\DART (PRQ)\Data\Krause and Byers.SRD.06-03-2022.dta", replace




*** DESCRIPTIVE STATISTICS OF POST-EMPLOYMENT VARIABLE [REASONS FOR DEPARTURE: NOTE: "9999" REPRESENTS THOSE CASES WHERE A REASON FOR DEPARTURE COULD NOT BE LOCATED]
*** SEE CODEBOOK FOR VARIABLE OPERATIONALIZATION AND DEFINITIONS [NOTE: THIS MEASURE IS EMPLOYED TO ESTIMATE THE COMPETING RISKS MODELS IN APPENDIX A] ***


tab postemployment





*******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************




** GENERATE CENSORING VARIABLE FOR HOLDOVER APPOINTEES SERVING BETWEEN/ACROSS ADMINISTRATIONS [=1]; UNCENSRED OBSERVATIONS [=0] ** 

gen singleadmin_service=1 if holdover==0
*
replace singleadmin_service=0 if holdover==1
*
*
tab singleadmin_service


** SET FOR SURVIVAL DATA WITH A SINGLE RECORD PER APPOINTEE OBSERVATION [N = 860: UNCENSORED N = 831; CENSORED N = 29] ** 
stset okapptdur, failure(singleadmin_service)
*

*
*
*
*

** ESTIMATE COX SEMIPARAMETRIC AND WEIBULL PARAMETRIC MODELS PRESENTED IN MANUSCRIPT [MODELS F1 - F4] ** 

** NOTE COVARIATES THAT VARY TRHOUGH TIME ARE BASED ON THE STARTING DATE OF APPOINTED SERVICE [I.E., "OKSTART....""]




**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************





*** MANUSCRIPT-BASED SURVIVAL REGRESSION ANALYSES: COX SEMIPARAMETRIC & WEIBULL PARAMETRIC MODELS ****




****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************




**** APPENDIX E REGRESSION MODELS  ***



**** MODEL E1: COX MODEL [OMISSION OF BOTH AGENCY AND PRESIDENTIAL ADMINISTRATION FIXED EFFECTS: CLUSTER-ADJUSTED STANDARD ERRORS BY AGENCY] ****

stcox   c.zloyalmedian##i.soubinaryagency2nom  zpecompmedian  zmecompmedian   toplevel2   presagencyideolalign  presagencyideolopposed subagencydesign standaloneagencydesign  okstartsenpolarizationmean okstartfilipresdistance   okcrossover okstartpresapp  okstartunemployment  i.okstartadyr i.postemployment,  hr vce(cluster sbagency)
*
estat ic

estimates store modelE1
estout modelE1, cells(b(star fmt(3)) se(par fmt(3))) eform


*** COMPUTE Figure E1: Interquartile Increase Marginal Effect Change of Appointee Loyalty on the HAZARD RATIO of APPOINTEE TENURE {PP − NPP Difference} {{4 [ME1−ME4] × 1 Horizontal Point Estimates and 95% CIs}}. ****
** NOTE: IQR = 1.3653231 [0.9692858 - (-0.3960373)] ***

  

** ONE INTERQUARTILE RANGE MARGINAL EFFECT INCREASE IN APPOINTEE LOYALTY DIFFERENTIAL BETWEEN POLICY PRIORITY AGENCY VERSUS NON-POLICY PRIORITY AGENCY [FIGURE E1] **

lincomest 1.soubinaryagency2nom#c.zloyalmedian*1.3653231, eform(hr)
matrix modelE1zloyal = r(table)
mat list modelE1zloyal
*



******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************



**** MODEL E2: COX MODEL [INCLUSION OF BOTH AGENCY AND PRESIDENTIAL ADMINISTRATION FIXED EFFECTS: CLUSTER-ADJUSTED STANDARD ERRORS BY AGENCY] ****

stcox   c.zloyalmedian##i.soubinaryagency2nom  zpecompmedian  zmecompmedian   toplevel2   presagencyideolalign  presagencyideolopposed subagencydesign standaloneagencydesign  okstartsenpolarizationmean okstartfilipresdistance   okcrossover okstartpresapp  okstartunemployment  i.okstartadyr  i.sbagency reagan bush41 clinton bush43 i.postemployment,  hr vce(cluster sbagency)
*
estat ic

estimates store modelE2
estout modelE2, cells(b(star fmt(3)) se(par fmt(3))) eform


*** COMPUTE Figure E1: Interquartile Increase Marginal Effect Change of Appointee Loyalty on the HAZARD RATIO of APPOINTEE TENURE {PP − NPP Difference} {{4 [ME1−ME4] × 1 Horizontal Point Estimates and 95% CIs}}. ****
** NOTE: IQR = 1.3653231 [0.9692858 - (-0.3960373)]  ***

lincomest 1.soubinaryagency2nom#c.zloyalmedian*1.3653231, eform(hr)
matrix modelE2zloyal = r(table)
mat list modelE2zloyal



**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************




**** MODEL E3: WEIBULL MODEL [OMISSION OF BOTH AGENCY AND PRESIDENTIAL ADMINISTRATION FIXED EFFECTS: CLUSTER-ADJUSTED STANDARD ERRORS BY AGENCY] ****

streg   c.zloyalmedian##i.soubinaryagency2nom  zpecompmedian  zmecompmedian   toplevel2   presagencyideolalign  presagencyideolopposed subagencydesign standaloneagencydesign  okstartsenpolarizationmean okstartfilipresdistance   okcrossover okstartpresapp okstartunemployment  i.okstartadyr i.postemployment,   distribution(weibull)  hr vce(cluster sbagency)
*
estat ic

estimates store modelE3
estout modelE3, cells(b(star fmt(3)) se(par fmt(3))) eform


*** COMPUTE Figure E1: Interquartile Increase Marginal Effect Change of Appointee Loyalty on the HAZARD RATIO of APPOINTEE TENURE {PP − NPP Difference} {{4 [ME1−ME4] × 1 Horizontal Point Estimates and 95% CIs}}. ****
** NOTE: IQR = 1.3653231 [0.9692858 - (-0.3960373)] ***

lincomest 1.soubinaryagency2nom#c.zloyalmedian*1.3653231, eform(hr)
matrix modelE3zloyal = r(table)
mat list modelE3zloyal



**** COMPUTE Figure E1: Interquartile Increase Marginal Effect Change of Appointee Loyalty on the MEDIAN NUMBER OF DAYS OF APPOINTEE TENURE {PP − NPP Difference} {{4 [ME1−ME4] × 1 Horizontal Point Estimates and 95% CIs}.
** NOTE: IQR = 1.3653231 [0.9692858 - (-0.3960373)] ***

** Generate 'manual' interaction variable ** 
generate loyalppdiff = soubinaryagency2nom*zloyalmedian

** Re-Estimate Model E2  with 'manual' interaction variable **
streg   zloyalmedian soubinaryagency2nom loyalppdiff  zpecompmedian  zmecompmedian   toplevel2   presagencyideolalign  presagencyideolopposed subagencydesign standaloneagencydesign  okstartsenpolarizationmean okstartfilipresdistance   okcrossover okstartpresapp okstartunemployment  i.okstartadyr i.postemployment, distribution(weibull) hr vce(cluster sbagency)

estimate store modelE2a


margins, predict(median time) at(loyalppdiff=(-0.3960373 0.9692858))

** Generate Differential Predicted Median Survival Time of Senate Committee Stage of Confirmation Process -- Based on Interquartile Differential [corresponding to Differential Marginal Hazard Ratio Estimates] **
margins, predict(median time) at(loyalppdiff=(-0.3960373 0.9692858))  contrast(atcontrast(r))
matrix modelE3azloyal = r(table)
mat list modelE3azloyal




estimates restore modelE2a

margins, predict(median time) at(loyalppdiff=(-0.6451644 1.711348))
margins, predict(median time) at(loyalppdiff=(-0.6451644 1.711348))  contrast(atcontrast(r))

matrix modelE3bzloyal = r(table)
mat list modelE3bzloyal





******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************



**** MODEL E4: WEIBULL MODEL [INCLUSION OF BOTH AGENCY AND PRESIDENTIAL ADMINISTRATION FIXED EFFECTS: CLUSTER-ADJUSTED STANDARD ERRORS BY AGENCY] ****

streg   c.zloyalmedian##i.soubinaryagency2nom  zpecompmedian  zmecompmedian   toplevel2   presagencyideolalign  presagencyideolopposed subagencydesign standaloneagencydesign  okstartsenpolarizationmean okstartfilipresdistance   okcrossover okstartpresapp okstartunemployment  i.okstartadyr i.postemployment  i.sbagency reagan bush41 clinton bush43 , distribution(weibull) hr vce(cluster sbagency)
*
estat ic

estimates store modelE4
estout modelE4, cells(b(star fmt(3)) se(par fmt(3))) eform



*** COMPUTE Figure E1: Interquartile Increase Marginal Effect Change of Appointee Loyalty on the HAZARD RATIO of APPOINTEE TENURE {PP − NPP Difference} {{4 [ME1−ME4] × 1 Horizontal Point Estimates and 95% CIs}}. ****
** NOTE: IQR = 1.3653231 [0.9746053 - (-0.3853984)]

lincomest 1.soubinaryagency2nom#c.zloyalmedian*1.3600037, eform(hr)
matrix modelE4zloyal = r(table)
mat list modelE4zloyal




**** COMPUTE Figure E2: Interquartile Increase Marginal Effect Change of Appointee Loyalty on the MEDIAN NUMBER OF DAYS OF APPOINTEE TENURE {PP − NPP Difference} {{4 [ME1−ME4] × 1 Horizontal Point Estimates and 95% CIs}.
** NOTE: IQR = 1.3653231 [0.9692858 - (-0.3960373)]

** Re-Estimate Model E4  with 'manual' interaction variable **
streg   zloyalmedian soubinaryagency2nom loyalppdiff  zpecompmedian  zmecompmedian   toplevel2   presagencyideolalign  presagencyideolopposed subagencydesign standaloneagencydesign  okstartsenpolarizationmean okstartfilipresdistance   okcrossover okstartpresapp okstartunemployment  i.okstartadyr i.postemployment i.sbagency reagan bush41 clinton bush43, distribution(weibull) hr vce(cluster sbagency)

estimates store modelE4a
margins, predict(median time) at(loyalppdiff=(-0.3960373 0.9692858))

** Generate Differential Predicted Median Survival Time of Senate Committee Stage of Confirmation Process -- Based on Interquartile Differential [corresponding to Differential Marginal Hazard Ratio Estimates] **
margins, predict(median time) at(loyalppdiff=(-0.3960373 0.9692858))  contrast(atcontrast(r))

matrix modelE4azloyal = r(table)
mat list modelE4azloyal



estimates restore modelE4a

margins, predict(median time) at(loyalppdiff=(-0.6451644 1.711348))
margins, predict(median time) at(loyalppdiff=(-0.6451644 1.711348))  contrast(atcontrast(r))

matrix modelE4bzloyal = r(table)
mat list modelE4bzloyal




***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************



*Figure E1

matrix pointmodel = modelE1zloyal[1,1], modelE2zloyal[1,1], modelE3zloyal[1,1], modelE4zloyal[1,1]

*
matrix cimodel = (modelE1zloyal[5,1], modelE2zloyal[5,1], modelE3zloyal[5,1], modelE4zloyal[5,1] \ modelE1zloyal[6,1], modelE2zloyal[6,1], modelE3zloyal[6,1], modelE4zloyal[6,1])

coefplot (matrix(pointmodel), ci((cimodel))), grid(none) xline(1, lcolor(red%40) lpattern(dash)) xtitle("Hazard Ratio", size(small) margin(t=2)) ylabel(1 "Model E1"  2 "Model E2"  3 "Model E3" 4 "Model E4", labsize(small) noticks) mlabel format(%9.3f) mlabposition(12) mlabsize(vsmall) xlabel(0(1)2, angle(0) labsize(small) format(%9.1f)) msymbol(o) mcolor(black) msize(small) title("FIGURE E1", size(small)) ciopts(lcolor(black)) legend(off) subtitle("Marginal Differential Effect of Presidential Loyalty on Appointee Tenure Hazard" "[Policy Priority Agencies versus Non-Policy Priority Agencies]", size(small))

graph save "Graph" "C:\Users\Jason\Dropbox\Jason Byers\Co-Authored Projects\Projects with George Krause\Krause Projects\Confirmation Dynamics Project\Appointee Tenure Project\Jason Byers\March 2023\DART (PRQ)\Graphics\FigureE1.gph", replace







***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************


*Figure E2

matrix pointmodelE1 = modelE3azloyal[1,1], modelE3bzloyal[1,1], modelE4azloyal[1,1], modelE4bzloyal[1,1]

*
matrix cimodel1 = (modelE3azloyal[5,1], modelE3bzloyal[5,1], modelE4azloyal[5,1], modelE4bzloyal[5,1] \ modelE3azloyal[6,1], modelE3bzloyal[6,1], modelE4azloyal[6,1], modelE4bzloyal[6,1])

coefplot (matrix(pointmodelE1), ci((cimodel1))), grid(none) xtitle("Predicted Number of Days", size(small) margin(t=2)) ylabel(1 `" "Model E3" "Interquartile Change" "' 2 `" "Model E3" "Interdecile Change" "' 3 `" "Model E4" "Interquartile Change" "'4 `" "Model E4" "Interdecile Change" "', labsize(small) noticks) mlabel format(%9.0f) mlabposition(12) mlabsize(vsmall) xlabel(0(100)800, angle(0) labsize(small) format(%9.0f))   msymbol(o) mcolor(black) msize(small) title("FIGURE E2", size(small)) ciopts(lcolor(black)) legend(off) subtitle("Marginal Differential Effect of Presidential Loyalty on Median Appointee Tenure" "[Policy Priority Agencies versus Non-Policy Priority Agencies]", size(small))

graph save "Graph" "C:\Users\Jason\Dropbox\Jason Byers\Co-Authored Projects\Projects with George Krause\Krause Projects\Confirmation Dynamics Project\Appointee Tenure Project\Jason Byers\March 2023\DART (PRQ)\Graphics\FigureE2.gph", replace




***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************


log close

